//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<XWindowManager.h>
///	@path	~/src/editor/wm/
///	@date	2008/05/16
///	@desc	Window Manager.

#pragma once

#pragma message("Compiling XWindowManager.h ...")

#include "editor/editor.h"

#include <map>

#include "editor/editor.h"

#include "gui/IGuiComp.h"
#include "gui/IGuiForm.h"
#include "gui/image/ImageResource.h"

#include "editor/wm/XEditorContainer.h"
#include "editor/wm/XFormView.h"
#include "editor/wm/XFormDialog.h"
#include "editor/wm/XFrameView.h"
#include "editor/wm/XEditorMain.h"

namespace xeres {

	// forward declaration
	class XWindowManager;

	namespace editor {

		// get global wm
		XWindowManager& wm( void );

	} // namespace editor

	/*! 
		\class	XWindowMangaer
	*/
	class XWindowManager
	{
	public:

		/// \brief	Attach main view.
		void AttachMainView( HWND mainFrame , XEditorMain * mainView );

		/// \brief	Get main view.
		XEditorMain& GetMain( void ) { return *m_mainView; }

		/// \brief	Get shelf form.


		/// \brief	Start a dialog.
		int OpenDialog( Ref<XForm> form );

		/// \brief	Close a dialog.
		void CloseDialog( int result );

	private:

		/// \brief	Tick called by dialog.
		static void TickByDialog( void );

		// instance access
		friend XWindowManager& editor::wm( void );

		/// \ctor
		XWindowManager( void );

		/// \dtor
		~XWindowManager( void );

		//@ data
		HWND					m_mainFrame;
		XEditorMain *			m_mainView;

		// Window id accumulator.
		int						m_id;

		// Opened frames.
		std::map<int,XFrameView*>	m_frames;

		// Nesting dialogs.
		std::deque<XFormDialog*>	m_dialogs;
	};

} // namespace xeres
